package org.sipsl.gisystems.gentest.rte.commands;

import java.io.BufferedWriter;
import java.io.FileWriter;

import org.sipsl.gisystems.gentest.rte.util.GenericUtil;
import org.sipsl.gisystems.gentest.rte.util.Params;
import org.sipsl.gisystems.gentest.rte.util.VoiceMoParams;
public class SetBundle extends RteCommand {
	
	private String s, startDate,  endDate,  startTime,  endTime;
	int type; // 1 data, 2 voiceMo
	
	public SetBundle(Params p, String s, String startDate, String endDate, String startTime, String endTime) {
		super(p);
		type = 1;
		this.s = s ;
		this.startDate = startDate ;
		this.endDate = endDate ;
		this.startTime = startTime ;
		this.endTime = endTime ;

		// TODO Auto-generated constructor stub
	}
	public String getScript(){
		//return "MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+p.getGeneric(s)+":SB_START_DATE,:SB_END_DATE,:SB_COST,:SB_START_TIME,:SB_END_TIME,;";
		return "MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+s+":SB_START_DATE,:SB_END_DATE,:SB_COST,:SB_START_TIME,:SB_END_TIME,;";
	}
	public void dumpScript(String title, int i){
		try  
		{
			String prefix = GenericUtil.MakePrefix(i);
		    FileWriter fstream = new FileWriter(title+"/"+prefix+":subbundle-New.hpp"); //true tells to append data.
		    BufferedWriter out = new BufferedWriter(fstream);
		    GenericUtil.LOG(title+"/"+prefix+":subbundle-New.hpp");
//		    GenericUtil.LOG("MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+p.getGeneric(s)+":SB_START_DATE,:SB_END_DATE,:SB_COST,:SB_START_TIME,:SB_END_TIME,;");
//		    out.write("MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+p.getGeneric(s)+":SB_START_DATE,:SB_END_DATE,:SB_COST,:SB_START_TIME,:SB_END_TIME,;\n");
		    GenericUtil.LOG("MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+s+":SB_START_DATE,"+startDate+":SB_END_DATE,"+endDate+":SB_COST,:SB_START_TIME,"+startTime+":SB_END_TIME,"+endTime+";");
		    out.write("MOD:SUBID,"+p.getMSISDN()+":ELEMENT,MAS01:IMOM_CMD,SUB_DTPBUNDLE:SB_CHANNEL_ID,:SB_PROMO_COS,"+s+":SB_START_DATE,"+startDate+":SB_END_DATE,"+endDate+":SB_COST,:SB_START_TIME,"+startTime+":SB_END_TIME,"+endTime+";\n");
		    out.flush();
		    out.close();
		    
		    testDescription = "Subscribe to bundle " + s ;

		}
		catch (Exception e)
		{
		    System.err.println("Error: " + e.getMessage());
		}
		
	}


}
